home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Development
/
General
/
MM3Tp.sea Folder
/
Made by Marksman
/
Sources
/
u
/
commonMM_Demo.p
< prev
next >
Wrap
Text File
|
1994-01-16
|
8KB
|
287 lines
unit CommonMM_Demo;
{ commonMM_Demo Common }
{ Copyright © 1994 George R. Cossey }
{
File name: commonMM_Demo
Function: Common variables for program specific code.
History: 1/16/94 Original by George Cossey
}
interface
uses
Printing, Folders, Sound,mmCommonMM_Demo;
{ ======================================================= }
{ ======================================================= }
{ NOTE : FormatRevision MUST be first in the record, and always a short }
type
PrefsHRec = ^PrefsPRec; {Handle definition}
PrefsPRec = ^PrefsRec; {Pointer definition}
PrefsRec = record { Preferences Record definition }
{ ALWAYS KEEP FormatRevision AS THE FIRST ELEMENT IN THIS RECORD }
FormatRevision:integer; { FIRST ALWAYS, Change each time the format changes }
theWindowLocRec:WindowLocRec; { For saving window positions }
{ Add other preference variable definitions after this line }
end;
{ ======================================================= }
const
PrefsCreator = 'xxxx'; { Creator, this has to be the same as your App }
PrefsType = 'Pref'; { Type, this has to match the type in your BNDL }
PrefsFormatRevision = 1; { Change each time the format changes }
procedure U_InitPreferences;
procedure U_GetPrefParams(var PrefCreator,PrefType:OSType;var thePrefsFilename:Str255;var PrefsRecSize:longint;var thePrefsFormatRevision:integer);
procedure U_ReadPrefsPrivate(PrefsRefNum:integer);
procedure U_GetPreferences(thePrefsH:Handle);
procedure U_SetPreferences(thePrefsH:Handle);
procedure Close_The_Input_File;
procedure Close_The_Output_File;
procedure Open_The_File;
procedure Select_Volume;
procedure Save_The_File;
procedure Print_The_Data;
{ ======================================================= }
{ ======================================================= }
implementation
{ ======================================================= }
{ ======================================================= }
{ Routine: U_InitPreferences }
{ Purpose: Set the default preferences }
procedure U_InitPreferences;
begin
end;
{ ======================================================= }
{ Routine: U_GetPrefParams }
{ Purpose: Get the preferences Parameters }
procedure U_GetPrefParams(var PrefCreator,PrefType:OSType;var thePrefsFilename:Str255;var PrefsRecSize:longint;var thePrefsFormatRevision:integer);
begin
PrefCreator := PrefsCreator;
PrefType := PrefsType;
thePrefsFilename := 'My Prefs';
PrefsRecSize := sizeof(PrefsRec);
thePrefsFormatRevision := PrefsFormatRevision;
end;
{ ======================================================= }
{ Routine: U_ReadPrefsPrivate }
{ Purpose: Read the prefs ourselves }
procedure U_ReadPrefsPrivate(PrefsRefNum:integer);
begin
end;
{ ======================================================= }
{ Routine: U_GetPreferences }
{ Purpose: Get the preferences from the Prefs record already read in }
procedure U_GetPreferences(thePrefsH:Handle);
var
thePrefs:PrefsHRec;
begin
thePrefs := PrefsHRec(thePrefsH);
theWindowLocRec := thePrefs^^.theWindowLocRec; { Get the window location data }
{ Use the form: xxxx := thePrefs^^.xxxx; }
end;
{ ======================================================= }
{ Routine: U_SetPreferences }
{ Purpose: Set new preferences, to be written out to the file }
procedure U_SetPreferences(thePrefsH:Handle);
var
thePrefs:PrefsHRec;
begin
thePrefs := PrefsHRec(thePrefsH);
thePrefs^^.FormatRevision := PrefsFormatRevision; { Version number }
thePrefs^^.theWindowLocRec := theWindowLocRec; { Save the window location data }
{ Use the form: thePrefs^^.xxxx := xxxx; }
end;
{ ======================================================= }
{ Routine: Close_The_Input_File }
{ Purpose: Close the input file }
procedure Close_The_Input_File;
var
ErrorCode:OSErr;
begin
ErrorCode := FSClose(Files.inputRefNum); { Invalidate the refnum }
Files.inputRefNum := 0; { Close the file }
end;
{ ======================================================= }
{ Routine: Close_The_Output_File }
{ Purpose: Close the output file }
procedure Close_The_Output_File;
var
ErrorCode:OSErr;
begin
ErrorCode := FSClose(Files.outputRefNum); { Invalidate the refnum }
Files.outputRefNum := 0; { Close the file }
end;
{ ======================================================= }
{ Routine: Open_The_File }
{ Purpose: Open the input file }
procedure Open_The_File;
var
NumberOfTypes,theVolRefNum:integer;
ErrorCode:OSErr;
begin
Files.typeList[0] := 'TEXT'; { Open TEXT files }
Files.typeList[1] := 'text'; { Open other files }
NumberOfTypes := 1; { Only use first filetype in the list }
if (Do_The_Open_File(NumberOfTypes,theVolRefNum,nil,nil)) then{ Try to open the file }
begin
ErrorCode := FSOpen(Files.inputFileName,Files.Reply.vRefNum,Files.inputRefNum);{ Open the file }
{ ADD in your code here to read the file }
Close_The_Input_File; { Now close this file }
end;
end;
{ ======================================================= }
{ Routine: Select_Volume }
{ Purpose: Select a volume }
procedure Select_Volume;
var
theFile:FSSpec;
begin
if (Has.NewStdFile) then { Do this if we have new Standard File available }
begin
if (Do_The_Select_Volume(theFile)) then
begin
end;
end
else
begin
end;
end;
{ ======================================================= }
{ Routine: Save_The_File }
{ Purpose: Save the file }
procedure Save_The_File;
var
theVolRefNum:integer;
theRefNum:integer;
begin
if (Do_The_Save_File('????','TEXT','Save as : ','Untitled ',theVolRefNum,theRefNum,nil)) then
begin
{ ADD in your code here to save the file }
Close_The_Output_File; { Now close this file }
end; { End of IF }
end;
{ ======================================================= }
{ Routine: Print_The_Data }
{ Purpose: Print the data }
procedure Print_The_Data;
var
ThePrintPort:GrafPtr; { Print port }
SavedPort:GrafPtr; { saved window port }
Doing_Page:integer; { Current print page number }
NumberOfCopies:integer; { Number of copies of each page }
Count:integer; { Number of copies of each page }
Cancelled:Boolean; { User cancelled flag }
NumberOfPages:integer; { Change this for the number of pages to do }
ThePageString:Str255; { For showing the page number }
begin
GetPort(SavedPort); { Get the current window port }
NumberOfPages := 2; { CHANGE for your pages limit }
OpenThePrinter(Cancelled); { Ask about the next page }
if ((Printing.pPrPort <> NIL) and (Printing.hPrint <> NIL) and (not(Cancelled))) then
begin
ThePrintPort := GrafPtr(Printing.pPrPort); { Get the current window port }
SetPort(ThePrintPort); { Point to the printer port }
TextFont(systemFont);
TextSize(12);
Doing_Page := 1;
repeat { Do all the pages in our document }
InitCursor;
PrOpenPage(Printing.pPrPort, nil); { Open a new page }
SetPort(ThePrintPort);
{ ADD YOUR PRINTING CODE HERE, DRAW INTO THIS PORT }
MoveTo(10, 20);
DrawString('Printing from Marksman ™code , page ');
NumToString(Doing_Page,ThePageString);
DrawString(ThePageString);
{ END OF ADD YOUR PRINTING CODE HERE }
PrClosePage(Printing.pPrPort); { Print this page }
SetPort(SavedPort);
Doing_Page := Doing_Page + 1; { Bump the page count }
until (Doing_Page > NumberOfPages);
end;
CloseThePrinter; { Close the printer }
SetPort(SavedPort);
InitCursor;
end;
{ ======================================================= }
{ ======================================================= }
end.